var currentIndexTemp = 0;
var date = "";
var fdReportDepartmentId;
var fdWorknumId;
var indexTemp = 0;
var frame;

efform_onload = function ()
{
	date = date2String();
	$("#inqu_status-0-fdVirtualDate").val(date);
}; 

function date2String(){
    var datetime = new Date();
    var year = datetime.getFullYear();
    var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
    var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
    return year + "-" + month + "-" + date;
}

button_query_onclick = function () 
{   
	frame = 0;
	date = 	$("#inqu_status-0-fdVirtualDate").val();
	fdReportDepartmentId = $("#inqu_status-0-fdReportDepartmentId").val();
	fdWorknumId = $("#inqu_status-0-fdWorknumId").val();
	if(date == ""){
		date = date2String();
		$("#inqu_status-0-fdVirtualDate").val(date);		
	}
		
	var info = getDetail("ef_region_inqu","inqu_status");
	if (null != info){ 
		if(indexTemp=='0')
		{
			fundiv(0,0);
		}
		if(indexTemp=='1')
		{
			fundiv(1,1);
		}
		if(indexTemp=='2')
		{
			fundiv(2,2);
		}
		if(indexTemp=='3')
		{
			fundiv(3,3);
		}
		if(indexTemp=='4')
		{
			fundiv(4,4);
		}
		if(indexTemp=='5')
		{
			fundiv(5,5);
		}
		if(indexTemp=='6')
		{
			fundiv(6,6);
		}
		if(indexTemp=='7')
		{
			fundiv(7,7);
		}
		efgrid.submitInqu( "ef_grid_result", "ZM", "ZMCG80", "query");
    } 
}

function fundiv(currentIndex, index){
	currentIndexTemp = currentIndex;
	indexTemp = index;
	if(index ==0){  
		frame = frames[0];
	    frame.src = "DispatchAction.do?efFormEname=ZMCG83&querydate="+date +"&inqu_status-0-fdReportDepartmentId=" + fdReportDepartmentId/*+"&inqu_status-0-fdWorknumId=" + fdWorknumId*/;
		efform.setStatus(0, "正在加载...");
	}else if(index ==1){ 
		frame = frames[1];
	    frame.src = "DispatchAction.do?efFormEname=ZMCG84&querydate="+date+"&inqu_status-0-fdReportDepartmentId=" + fdReportDepartmentId/*+"&inqu_status-0-fdWorknumId=" + fdWorknumId*/;
		efform.setStatus(0, "正在加载...");
	}else if(index ==2){ 
		frame = frames[2];
		frame.src = "DispatchAction.do?efFormEname=ZMCG85&querydate="+date+"&inqu_status-0-fdReportDepartmentId=" + fdReportDepartmentId/*+"&inqu_status-0-fdWorknumId=" + fdWorknumId*/;
		efform.setStatus(0, "正在加载...");
	}else if(index ==3){
		frame = frames[3];
	    frame.src = "DispatchAction.do?efFormEname=ZMCG86&querydate="+date;
		efform.setStatus(0, "正在加载...");
	}else if(index ==4){
		frame = frames[4];
		frame.src = "DispatchAction.do?efFormEname=ZMCG82&querydate="+date;
		efform.setStatus(0, "正在加载...");
	}else if(index ==5){
		frame = frames[5];
		frame.src = "DispatchAction.do?efFormEname=ZMCG50&flag=hidden&querydate="+date;
		efform.setStatus(0, "正在加载...");
	}else if(index ==6){
		frame = frames[6];
		frame.src = "DispatchAction.do?efFormEname=ZMCG72&flag=hidden&querydate="+date;
		efform.setStatus(0, "正在加载...");
	}else if(index ==7){ 
		frame = frames[7];
		frame.src = "DispatchAction.do?efFormEname=ZMCG71&flag=hidden&querydate="+date;
		efform.setStatus(0, "正在加载...");
	} 
} 

button_print_onclick = function() {
	var fdMiningId = $('#inqu_status-0-fdMiningId').val();
	var fdVirtualDate = $('#inqu_status-0-fdVirtualDate').val();
//	if(fdMiningId =="C.10202")
//		fdMiningId="C.10203";
//	if(fdMiningId == "C.10205")
//		fdMiningId="C.10204";
	// 取报表参数
	var param = [];
	param.fdVirtualDate =fdVirtualDate;
	param.fdMiningId =fdMiningId;
	var reportEname = "ZMKDDRB";
	try {
		previewReport(reportEname,param);
	} catch (e) {
		alert("控件加载失败，请确认控件是否正确安装并将本网站设为信任地址");
	}
}

//刷新表格数据方法
refresh_grid = function() {
	var ajax_callback =
	{
		onSuccess :
    		function(eiInfo)
			{
				
				grid = efgrid.getGridObject("ef_grid_result");
				grid.refresh(eiInfo);
				var fdMineSumDsum = grid.getCellValueByColumnName(0,"fdMinesumDsum");
				var fdMineMzsumDsum = grid.getCellValueByColumnName(0,"fdMineMzSumDsum");
				if(fdMineSumDsum>0&&fdMineMzsumDsum>0){
				var chazhi =Number(fdMineMzsumDsum)-Number(fdMineSumDsum);
				if(Number(chazhi)==Number(0)){
					EFAlert("与煤质采煤数值相等！！！")
				}else{
				EFAlert("所差值为："+chazhi+"!!!");
				}
				}
    		},
  		onFail:
    		function(eMsg)
			{
  				EFAlert("服务调用失败，原因：" + eMsg ,"警告");
			}
	};

	var info = new EiInfo();
	info.set("fdVirtualDate", date);
  	EiCommunicator.send( "ZMCG80", "initLoad", info, ajax_callback );
}
//掘进刷新
refresh_JJgrid = function() {
	var ajax_callback =
	{
		onSuccess :
    		function(eiInfo)
			{
				grid = efgrid.getGridObject("ef_grid_result");
				grid.refresh(eiInfo);
				}
    		,
  		onFail:
    		function(eMsg)
			{
  				EFAlert("服务调用失败，原因：" + eMsg ,"警告");
			}
	};
	var info = new EiInfo();
	info.set("fdVirtualDate", date);
  	EiCommunicator.send( "ZMCG80", "initLoad", info, ajax_callback );
}
